﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>采购申请列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link href="~/js/layui/css/layui.css" rel="stylesheet" />
    <link href="~/X-admin/css/font.css" rel="stylesheet" />
    <script src="~/X-admin/lib/layui/layui.js"></script>
    <link href="~/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/X-admin/js/jquery.min.js"></script>
    <script src="~/X-admin/js/xadmin.js"></script>
    <script src="~/js/framework/sysframework.js"></script>
    <script src="~/js/framework/commonjs.js"></script>
    <script src="~/js/sysweb/planjs.js"></script>
@*     <script type="text/html" id="barDemo">
        <a title="确认处理" href="javascript:;" lay-event="do" id="do"><i class="layui-icon">&#xe663;</i></a>
    </script> *@

    <style>
        .layui-table-cell {
            height: auto !important;
        }
    </style>

</head>
<body>
    <div class="layui-fluid">
        <div id="bDiv">
        </div>
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">

                    <div class="layui-card-body ">
                        <form class="layui-form layui-col-space5" name="qForm" id="qForm">
                            <div class="layui-inline layui-show-xs-block">
                                <input type="text" id="relationOrder" name="relationOrder" placeholder="关联计划" autocomplete="off" class="layui-input">
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <select id="isFinish" name="isFinish">
                                    <option value="">不 限</option>
                                    <option value="0" selected>未处理</option>
                                    <option value="1">已处理</option>
                                </select>
                            </div>

                        </form>
                    </div>

                    <div class="layui-card-body" id="layui-table-main">
                        <table class="layui-hide" id="list" lay-filter="list"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>

</html>


<script>
    var currPage = 1;//首先默认值为1，防止出错
    var ids = "";
    var dUrl = "../Plan/getDataList?dataType=purchase&condition=";

    var webCode = "";

    $(function () {
        webCode = getUrlVariable("menuCode");
        BannerData(webCode, "bDiv");

        loadData();
        $(document).keyup(function (event) {
            if (event.keyCode == 13) {
                loadData();
            }
        })
    })

    /**
     * 加载列表数据
     * **/
    function loadData() {

        layui.use('table', function () {
            var conditon = JSON.stringify(FormToJson("qForm"));
            var table = layui.table;
            table.render({
                elem: '#list'
                ,height: 'full-200'   //固定高度-即固定表头固定第一行首行
                //,lineStyle: 'height: 95px'
                , cols: [[ //标题栏
                    // { field: 'relationOrder', title: '关联单据', width: 120 },
                    { type: 'checkbox' }
                    // { field: 'id', align: 'center', title: '任务编码', width: '13%', sort: true }
                    , { field: 'relationOrder',  title: '关联计划', width: 120, sort: true }
                    , { field: 'businessTypeName', title: '任务类型', width: 100, sort: true }
                    , { field: 'createtime',title: '创建时间', width: 150, sort: true }
                    , { field: 'isFinishName',  title: '是否处理', width: 100, sort: true }
                    , {
                        field: 'text', title: '详情', width: 300, sort: true, templet: function (d) {
                            return '<text class="layui-text" style="height:100px">' + d.text + '</text>';
                        }
                    }
                    
                ]], done: function (res, curr, count) {
                    currPage = curr;
                   
                }
                , url: dUrl + conditon
                , skin: 'row' //表格风格
                , even: true
                , page: true //是否显示分页
                , limits: [20, 25, 30]
                , limit: 20 //每页默认显示的数量
                , id: "tData"
            });
            
            table.on('checkbox(list)', function (obj) {
                ids = "";
                var cDatas = table.checkStatus('tData');
                for (var i = 0; i < cDatas.data.length; i++) {
                    ids += cDatas.data[i].id + ",";
                }
                ids = ids.substr(0, ids.length - 1);

            });
            
        });
    }

   //确认处理
    function Confirm() { 
        if (ids == "") {
            layer.msg("您没有选择任何数据"); return;
        }else{
            $.ajax({
                url: "../Plan/ConfirmTask",
                data: { "ids": ids },
                type: "post",
                success: function (data) {
                    if (data.result) {
                        layer.msg("已处理"); 
                        loadData();
                    } else {
                        layer.msg(data.message);
                    }
                }
            });
        }
    }

</script>
